package cn.tedu._05mvcboot.controller;

import cn.tedu._05mvcboot.pojo.dto.BmiDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {

    @RequestMapping("/bmi")
    @ResponseBody
    public String bmi(Double weight, Double height){
        double bmi = weight / (height * height);
        if (bmi < 18.5) {
            return "过轻";
        } else if (bmi < 24) {
            return "正常";
        } else if (bmi < 28) {
            return "过重" + bmi;
        } else if (bmi < 32) {
            return "肥胖";
        } else {
            return "严重肥胖";
        }
    }

    @RequestMapping("/bmi1")
    @ResponseBody
    public String bmi1(BmiDTO dto){
        double bmi = dto.getWeight() / (dto.getHeight() * dto.getHeight());
        if (bmi < 18.5) {
            return "过轻";
        } else if (bmi < 24) {
            return "正常";
        } else if (bmi < 28) {
            return "过重";
        } else if (bmi < 32) {
            return "肥胖";
        } else {
            return "严重肥胖";
        }
    }

}
